package com.styles.codingstylemybatis.controller;

import com.styles.codingstylemybatis.mapper.entitymapper.UserMapper;
import com.styles.codingstylemybatis.pojo.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chenjian
 * @Package
 * @Description:
 * @date 2018/10/30 1:31
 */
@RestController
public class IndexController {

    @Autowired
    private UserMapper userMapper;

    @GetMapping(value = "/index")
    public String index() {
        List<UserEntity> all = userMapper.selectAll();
        for (UserEntity userEntity : all) {
            System.out.println(userEntity);
        }
        return "ok";
    }
    @GetMapping("/save")
    public Integer save(){
        UserEntity userEntity = new UserEntity();

        userEntity.setUserName("ceshi");
        userEntity.setPassword("123456");
        int insert = userMapper.insert(userEntity);
        return insert;
    }
}
